package com.example.fengyungo.service.impl;

import com.example.fengyungo.constant.OrderDriverConstant;
import com.example.fengyungo.dao.OrderDriverDao;
import com.example.fengyungo.domain.pojo.OrderDriver;
import com.example.fengyungo.service.OrderDriverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderDriverServiceImpl implements OrderDriverService {

    @Autowired
    private OrderDriverDao orderDriverDao;

    /**
     * 司机愿意接收订单，等待用户回应
     *
     * @param orderDriver OrderDriver
     * @return Integer
     */
    @Override
    public Integer addOrderDriver(OrderDriver orderDriver) {
        return orderDriverDao.addOrderDriver(orderDriver);
    }

    /**
     * 查询愿意接收订单的司机
     *
     * @param number 订单编号
     * @return List<OrderDriver>
     */
    @Override
    public List<OrderDriver> getOrderDriverByNumber(String number) {
        return orderDriverDao.getOrderDriverByNumber(number);
    }

    /**
     * 司机取消订单
     *
     * @param orderDriver OrderDriver
     * @return Integer
     */
    @Override
    public Integer cancelAcceptOrder(OrderDriver orderDriver) {
        orderDriver.setStatus(OrderDriverConstant.CANCEL);
        return orderDriverDao.updateOrderDriverStatus(orderDriver);
    }
}
